package cn.factorybox.item.controller;

import cn.factorybox.common.entity.Result;
import cn.factorybox.item.annotation.ControllerLogAnnotation;
import cn.factorybox.item.service.SystemLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author flypig
 * @version 1.0
 * @date 2020-04-20 23:25
 */

@Api(tags = "日志管理")
@RestController
@RequestMapping("log")
public class SystemLogController {

    @Autowired
    private SystemLogService systemLogService;

    @ControllerLogAnnotation(moduleName = "日志管理", functionName = "获取今日用户登录动态")
    @ApiOperation(value = "获取今日用户登录动态",notes = "获取今日用户登录动态")
    @GetMapping("todaylogin")
    public Result selectTodayLogin() {
        Map<String,Object> map = systemLogService.selectTodayUserLogin();
        return Result.ok(map,"成功获取用户动态");
    }

    @ControllerLogAnnotation(moduleName = "日志管理", functionName = "获取最近一周的操作日志")
    @ApiOperation(value = "获取最近一周的操作日志",notes = "获取最近一周的操作日志")
    @GetMapping("operation")
    public Result selectOperationRecords() {
        Map<String,Object>  map = systemLogService.selectOperationLogs();
        return Result.ok(map,"成功获取用户动态");
    }
}


